package ma.fizazi.missionsmanagement.presentation.components;

import java.beans.PropertyEditorSupport;

import ma.fizazi.missionsmanagement.business.clients.ClientBusiness;
import ma.fizazi.missionsmanagement.model.Client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ClientEditor extends PropertyEditorSupport {

	@Autowired
    ClientBusiness clientBusiness;

    // Converts a String to a client (when submitting form)
    
	@Override
    public void setAsText(String text) {
        //Country c = this.countryService.findById(Long.valueOf(text));
        Client client = this.clientBusiness.getClientById(Integer.valueOf(text));
        this.setValue(client);
    }
	
}
